package liuyuyang.controller;

import liuyuyang.pojo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/text")
public class TextController {
    @Resource
    private HttpServletRequest httpServletRequest;

    @GetMapping
    public Result<String> test() {

        //端口号
        System.out.println("服务器端口号：" + httpServletRequest.getServerPort());
        System.out.println("远程端口号（浏览器）：" + httpServletRequest.getRemotePort());

        //打印IP地址
        System.out.println("本地IP地址（服务器）：" + httpServletRequest.getLocalAddr());
        System.out.println("远程IP地址（浏览器）：" + httpServletRequest.getRemoteAddr());

        return Result.success("成功");
    }
}
